package com.aaa.service.impl;

import com.aaa.entity.Menu;
import com.aaa.entity.quanxian;
import com.aaa.mapper.BackUserMapper;
import com.aaa.mapper.MenuMapper;
import com.aaa.service.MenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: MenuService
 * @Description: TODO
 * @Author: 86139
 * @Date: 2021/9/3 22:08
 * @Version:1.0
 **/
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper,Menu> implements MenuService {
    @Resource
    MenuMapper menuMapper;
    public List<Map<String,Object>> addAfter(String username){
        return menuMapper.addAfter(username);
    }
    public List<Map<String,Object>> addBfore(Integer username){
        return menuMapper.addBfore(username);
    }

    public List<Menu> finByMnane(){
        List<Menu> byPid = menuMapper.menuSelect(0);
        return byPid;
    }
//    rolr权限
    public List<Menu> menuSelect(){
        List<Menu> byPid = menuMapper.menuSelect(0);
        for (Menu menus:byPid) {
            List<Menu> byPid1 = menuMapper.menuSelect(menus.getMid());
            menus.setChildren(byPid1);
            System.out.println(menus);
        }
        System.out.println(byPid);
        return byPid;
    }
//    menu表查询全部
    public List<Menu> finAll(){
        List<Menu> byPid = menuMapper.finAll(0);
        for (Menu menus:byPid) {
            List<Menu> byPid1 = menuMapper.finAll(menus.getMid());
            menus.setChildren(byPid1);
            System.out.println(menus);
        }
        System.out.println(byPid);
        return byPid;
    }
    public List<Menu> finByRid(Integer rid){
        List<Menu> byPid = menuMapper.finByRid(rid,0);
        for (Menu menus:byPid) {
            List<Menu> byPid1 = menuMapper.finByRid(rid,menus.getMid());
            menus.setChildren(byPid1);
            System.out.println(menus);
        }
        System.out.println(byPid);
        return byPid;
    }
    public List<Integer> allMid(Integer rid){
        return menuMapper.allMid(rid);
    }
    public String quanxian(Integer rid){
        return menuMapper.quanxian(rid);
    }
}
